home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / CMCD0505.ISO / Software / Demo / DesktopX / objects / ktekdockv1.dxpack / {DBA771A0-A28D-4A8D-BD75-1E5C6D9719A4}.DXScript2 < prev    next >
Extensible Markup Language  |  2004-08-24  |  14KB  |  413 lines

  1. <?xml version="1.0"?>
  2. <!--DXScript Data File.  Version 2.0-->
  3. <DXScript>
  4.     <Script><![CDATA[Dim x1,y1,x2,y2
  5. Dim ExpandType
  6. Dim appon
  7. Dim secstart,secgap
  8. Dim shortcuts()
  9. Dim sections()
  10. Dim totalheight
  11. Dim tt
  12.  
  13. 'Called when the script is executed
  14. Sub Object_OnScriptEnter
  15.     DesktopX.Object("kbarback").move 0,0
  16.     ExpandType = 2'1 = Only one panel open at once, 2 = All panels toggle
  17.     appon = True' Set default appbar state to Docked (use false for AutoHide)
  18.     secstart=32
  19.     secgap=0
  20.     loadsettings
  21.     'initializesections'use this instead of load sections when I want to manually configure sections
  22.     loadsections
  23.     loadlogo
  24.     DesktopX.ScriptObject("kdockweatherimage").Object.SetTimer 6001, 600000
  25.     DesktopX.ScriptObject("kdockweatherimage").Object_OnTimer6001
  26.     Object_OnStateChange "Command executed"
  27.     checkshortcuts
  28.     'msgbox UBound(shortcuts)
  29.     populateshortcuts
  30.     displaysections
  31. End Sub
  32.  
  33. Sub Object_OnStateChange(state)
  34.     If state = "Command executed" Then
  35.         x1=desktopx.Object("wmp_viewer_back").left
  36.         y1=desktopx.Object("wmp_viewer_back").top
  37.         x2=desktopx.Object("wmp_back").left
  38.         y2=desktopx.Object("wmp_back").top
  39.         If appon = True Then
  40.             DesktopX.Object("kbarback").AppbarMode = 1 ' 1=Docked,2=autohide
  41.             appon = False
  42.             tt = "Click to autohide the bar"
  43.             'Object.State = "Docked"
  44.         Else
  45.             DesktopX.Object("kbarback").AppbarMode = 2 ' Autohide
  46.             appon = True
  47.             tt = "Click to lock the bar"
  48.             'Object.State = "Undocked"
  49.         End If
  50.         object.SetTimer 1,3000
  51.     End If
  52. End Sub
  53.  
  54. Sub Object_OnTimer1
  55.     desktopx.Object("wmp_viewer_back").move x1,y1
  56.     desktopx.Object("wmp_back").move x2,y2
  57.     object.KillTimer 1
  58. End Sub
  59.  
  60. Function tagstrip(searchtext,tag)
  61.     tagS="<"&tag&">"
  62.     tagF="</"&tag&">"
  63.     start=Instr(1,searchtext,tagS)+Len(tagS)
  64.     If start=Len(tagS) Then 
  65.         tagstrip=""
  66.     Else
  67.         finish=Instr(start,searchtext,tagF,1)    
  68.         tagstrip=Mid(searchtext,start,finish-start)
  69.     End If
  70.     Set tagS=nothing
  71.     Set tagF=nothing
  72.     Set start=nothing
  73.     Set finish=nothing
  74. End Function
  75.  
  76. '=======================================SECTIONS========================================
  77.  
  78. Sub renamesection(num)
  79.     title=DesktopX.Object("sectiontitle" & num).text    
  80.     For x = 0 To UBound(sections)
  81.         sectioninfo = sections(x)
  82.         t=tagstrip(sectioninfo,"t")
  83.         s=tagstrip(sectioninfo,"s")
  84.         n=tagstrip(sectioninfo,"n")
  85.         eh=tagstrip(sectioninfo,"eh")
  86.         ch=tagstrip(sectioninfo,"ch")
  87.         g=tagstrip(sectioninfo,"g")
  88.         If t = title Then'ask for user input for new section title
  89.             Do
  90.                 t=InputBox("Enter the new section title"&Chr(13)&"(15 characters or less)","K-Dock",title)
  91.                 unique=True
  92.                 For y = 0 To UBound(sections)'uniqueness check
  93.                     sectioninfo = sections(y)
  94.                     t2=tagstrip(sectioninfo,"t")
  95.                     n2=tagstrip(sectioninfo,"n")
  96.                     If n2<>n And t2=t Then 
  97.                         unique=False
  98.                         m=msgbox("That title is already in use"&Chr(13)&"Please enter a unique title",53,"K-Dock")
  99.                         If m=2 Then Exit Sub
  100.                     End If
  101.                 Next
  102.             Loop Until Len(t)<=15 And unique
  103.             If t="" Then Exit Sub
  104.             sections(x) = "<t>"&t&"</t><s>"&s&"</s><eh>"&eh&"</eh><ch>"&ch&"</ch><n>"&n&"</n><g>"&g&"</g>"
  105.         End If
  106.     Next
  107.     displaysections
  108.     savesections
  109.     Set m=nothing
  110. End Sub
  111.  
  112. Sub movesection(num,d)
  113.     title=DesktopX.Object("sectiontitle" & num).text    
  114.     For x = 0 To UBound(sections)
  115.         sectioninfo = sections(x)
  116.         n=tagstrip(sectioninfo,"n")            
  117.         t=tagstrip(sectioninfo,"t")
  118.         If t=title Then num=Cint(n)
  119.     Next
  120.     If (d=-1 And num<>1) Or (d=1 And num<>(UBound(sections)+1)) Then
  121.         For x = 0 To UBound(sections)
  122.             sectioninfo = sections(x)
  123.             n=Cint(tagstrip(sectioninfo,"n"))            
  124.             t=tagstrip(sectioninfo,"t")
  125.             s=tagstrip(sectioninfo,"s")
  126.             eh=tagstrip(sectioninfo,"eh")
  127.             ch=tagstrip(sectioninfo,"ch")
  128.             g=tagstrip(sectioninfo,"g")
  129.             If n=num Then    
  130.                 sections(x) = "<t>"&t&"</t><s>"&s&"</s><eh>"&eh&"</eh><ch>"&ch&"</ch><n>"&n+d&"</n><g>"&g&"</g>"
  131.             ElseIf n=num+d Then
  132.                 sections(x) = "<t>"&t&"</t><s>"&s&"</s><eh>"&eh&"</eh><ch>"&ch&"</ch><n>"&n-d&"</n><g>"&g&"</g>"
  133.             End If
  134.         Next
  135.     End If
  136.     displaysections
  137.     savesections
  138. End Sub
  139.  
  140. Sub togglesection(num)
  141.     title=DesktopX.Object("sectiontitle" & num).text
  142.     For x = 0 To UBound(sections)
  143.         sectioninfo = sections(x)
  144.         t=tagstrip(sectioninfo,"t")
  145.         If t=title Then group=tagstrip(sectioninfo,"g")
  146.     Next
  147.     For x = 0 To UBound(sections)
  148.         sectioninfo = sections(x)
  149.         t=tagstrip(sectioninfo,"t")
  150.         s=tagstrip(sectioninfo,"s")
  151.         n=tagstrip(sectioninfo,"n")
  152.         eh=tagstrip(sectioninfo,"eh")
  153.         ch=tagstrip(sectioninfo,"ch")
  154.         g=tagstrip(sectioninfo,"g")
  155.         If t = title Then
  156.             If s=1 Then
  157.                 s=0
  158.             Else
  159.                 s=1
  160.             End If
  161.             sections(x) = "<t>"&t&"</t><s>"&s&"</s><eh>"&eh&"</eh><ch>"&ch&"</ch><n>"&n&"</n><g>"&g&"</g>"
  162.         Else
  163.             If (g=1 And group=1) Or (g=2 And group=2 And system.WorkareaBottom<730) Then    'if grouping=1 then shortcut, so hide all inactive
  164.                 s=0                                                                                                                                                    'or if 2, and small screen, toggle calendar and weather
  165.                 sections(x) = "<t>"&t&"</t><s>"&s&"</s><eh>"&eh&"</eh><ch>"&ch&"</ch><n>"&n&"</n><g>"&g&"</g>"
  166.             End If
  167.         End If
  168.     Next
  169.     displaysections
  170.     savesections
  171. End Sub
  172.  
  173. Sub displaysections
  174.     t = secstart
  175.     For y = 1 To (UBound(sections)+1)
  176.     For x = 0 To UBound(sections)
  177.         sectioninfo = sections(x)
  178.         n=Cint(tagstrip(sectioninfo,"n"))
  179.         If n=y Then
  180.         title = tagstrip(sectioninfo,"t")    
  181.         If tagstrip(sectioninfo,"s") = "1" Then                                        ' Code for panel to expand
  182.             DesktopX.Object("sectiontitle" & x+1).text=title
  183.             DesktopX.Object("section" & x+1).Height=tagstrip(sectioninfo,"eh")
  184.             DesktopX.Object("kcontainer" & x+1).Height=tagstrip(sectioninfo,"eh")-22
  185.             DesktopX.Object("kcontainer" & x+1).visible=True
  186.             desktopx.Object("section"&x+1).opacity=100'<====
  187.         Else                                                                                                            ' Code for panels to collapse
  188.             DesktopX.Object("sectiontitle" &x+1).text=title
  189.             DesktopX.Object("section" & x+1).Height=tagstrip(sectioninfo,"ch")
  190.             DesktopX.Object("kcontainer" & x+1).visible=False
  191.             'desktopx.Object("section"&x+1).opacity=0'<====
  192.         End If
  193.         DesktopX.Object("section" & x+1).Top = t    
  194.         t = t + DesktopX.Object("section" & x+1).Height + secgap
  195.         End If
  196.     Next
  197.     Next
  198.     totalheight=t-secgap
  199.     spare=desktopx.Object("kbarback").height-totalheight
  200.     If spare>130 Then
  201.         desktopx.Object("kdockdove").bottom=desktopx.Object("kbarback").height-(spare-desktopx.Object("kdockdove").height)/2
  202.         desktopx.Object("kdockdove").visible=True
  203.     Else
  204.         desktopx.Object("kdockdove").visible=False
  205.     End If
  206. End Sub
  207.  
  208. '=======================================SHORTCUTS=======================================
  209.  
  210. Sub checkshortcuts
  211.     Dim sstemp()'<====
  212.     newparams=False
  213.     numcuts=0'<====
  214.     For i=1 To 30
  215.         infoexists=False
  216.         If desktopx.IsObject("shortcutback"&i) Then'for every shortcut object...            
  217.             For x= 0 To UBound(shortcuts)
  218.                 shortcutinfo=shortcuts(x)
  219.                 n=Cint(tagstrip(shortcutinfo,"n"))
  220.                 If n=i Then'...check that parameters are defined
  221.                     infoexists=True
  222.                     Exit For
  223.                 End If
  224.             Next
  225.             If infoexists=False Then'...if they aren't
  226.                 x=UBound(shortcuts)+1
  227.                 ReDim Preserve shortcuts(x)
  228.                 shortcuts(x)="<p>notepad.exe</p><c>notepad</c><n>"&i&"</n>"'...create an extra entry
  229.                 newparams=True
  230.             End If
  231.             ReDim Preserve sstemp(numcuts)'<====
  232.             sstemp(numcuts)=shortcuts(x)'<====
  233.             numcuts=numcuts+1'<====
  234.         End If
  235.     Next
  236.     For x=0 To UBound(sstemp)'<====
  237.         ReDim Preserve shortcuts(x)'<====
  238.         shortcuts(x)=sstemp(x)'<====
  239.     Next'<====
  240.     savesettings'<====
  241.     'If newparams Then savesettings
  242. End Sub
  243.  
  244. Sub redefineshortcut(num,p,c)
  245.     For x = 0 To UBound(shortcuts)
  246.         shortcutinfo=shortcuts(x)
  247.         n=tagstrip(shortcutinfo,"n")
  248.         If n=num Then
  249.             shortcuts(x)="<p>"&p&"</p><c>"&c&"</c><n>"&num&"</n>"
  250.             populateshortcuts
  251.             savesettings
  252.             Exit Sub
  253.         End If
  254.     Next
  255.     checkshortcuts
  256.     populateshortcuts
  257. End Sub
  258.  
  259. Sub launchshortcut(num)
  260.     Set MyShell = CreateObject("WScript.Shell")
  261.     For x = 0 To UBound(shortcuts)
  262.         shortcutinfo=shortcuts(x)
  263.         n=tagstrip(shortcutinfo,"n")
  264.         If n=num Then
  265.             thepath=tagstrip(shortcutinfo,"p")
  266.             MyShell.Run (Chr(34)&thepath&Chr(34))
  267.             Exit Sub
  268.         End If
  269.     Next    
  270.     checkshortcuts
  271.     populateshortcuts    
  272. End Sub
  273.  
  274. Sub populateshortcuts
  275.     For x = 0 To UBound(shortcuts)
  276.         shortcutinfo=shortcuts(x)
  277.         thepath=tagstrip(shortcutinfo,"p")
  278.         thecaption=tagstrip(shortcutinfo,"c")
  279.         n=tagstrip(shortcutinfo,"n")
  280.         desktopx.Object("shortcutcaption"&n).text=thecaption
  281.         desktopx.ScriptObject("shortcutback"&n).Object.LocalStorage("p")=thepath
  282.     Next
  283. End Sub
  284.  
  285. '===================================LOADING AND SAVING==================================
  286. Sub loadsettings'loads settings string from reg (And Set If Not existing):
  287.     Set Sh = CreateObject("WScript.Shell")
  288.     On Error Resume Next
  289.     thecolourscheme = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\thecolourscheme")
  290.     t_units = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\t_units")
  291.     DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("t_units") = t_units
  292.     w_units = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\w_units")
  293.     DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("w_units") = w_units
  294.     x = Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\zipcode")
  295.     DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("zipcode") = x    
  296.     shortcutstring=Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\shortcutstring")
  297.     sstemp=split(shortcutstring,"|")
  298.     For x=0 To UBound(sstemp)
  299.         ReDim Preserve shortcuts(x)
  300.         shortcuts(x)=sstemp(x)
  301.     Next    
  302.     If err.number <> 0 Then
  303.         thecolourscheme="blue"
  304.         DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("t_units") = "imperial"
  305.         DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("w_units") = "imperial"
  306.         DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("zipcode") = "UKXX0929"
  307.         ReDim shortcuts(0)
  308.         shortcuts(0)="<p>notepad.exe</p><c>notepad</c><n>1</n>"
  309.         savesettings
  310.         err.clear
  311.     End If
  312.     Set x = Nothing
  313.   Set Sh = Nothing
  314. End Sub
  315.  
  316. Sub savesettings'writes the settings string to the registry
  317.     For x = 0 To UBound(shortcuts)
  318.         If x=0 Then
  319.             shortcutstring=shortcuts(x)
  320.         Else
  321.             shortcutstring=shortcutstring&"|"&shortcuts(x)
  322.         End If
  323.     Next
  324.     Set Sh = CreateObject("WScript.Shell")
  325.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\thecolourscheme", thecolourscheme
  326.     t_units = DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("t_units")
  327.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\t_units", t_units
  328.     w_units = DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("w_units")
  329.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\w_units", w_units
  330.     x = DesktopX.ScriptObject("kdockweatherimage").Object.PersistStorage("zipcode")
  331.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\zipcode", x
  332.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\shortcutstring", shortcutstring
  333.     Set Sh = Nothing
  334.     Set shortcutstring = Nothing
  335.     Set x = Nothing
  336.     Set t_units = Nothing
  337.     Set w_units = Nothing
  338. End Sub
  339.  
  340. Sub loadlogo
  341.     Set Sh = CreateObject("WScript.Shell")
  342.     On Error Resume Next
  343.     logostate=Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\logostate")
  344.     If err.number <> 0 Then
  345.         logostate="dove"
  346.         err.clear
  347.     End If
  348.     desktopx.object("kdockdove").state=logostate
  349.     Set Sh = Nothing
  350.     Set logostate=nothing
  351. End Sub
  352. Sub savelogo(s)
  353.     Set Sh = CreateObject("WScript.Shell")
  354.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\logostate", s
  355.     Set Sh = Nothing
  356. End Sub
  357.  
  358. Sub loadsections
  359.     Set Sh = CreateObject("WScript.Shell")
  360.     On Error Resume Next
  361.     sectionstring=Sh.RegRead("HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\sectionstring")
  362.     sstrtemp=split(sectionstring,"|")
  363.     For x=0 To UBound(sstrtemp)
  364.         ReDim Preserve sections(x)
  365.         sections(x)=sstrtemp(x)
  366.     Next
  367.     If err.number <> 0 Then
  368.         initializesections
  369.         savesections
  370.         err.clear
  371.     End If
  372.   Set Sh = Nothing
  373.   Set x = Nothing
  374.   Set sectionstring = Nothing
  375. End Sub
  376. Sub savesections
  377.     For x = 0 To UBound(sections)
  378.         If x=0 Then
  379.             sectionstring=sections(x)
  380.         Else
  381.             sectionstring=sectionstring&"|"§ions(x)
  382.         End If
  383.     Next
  384.     Set Sh = CreateObject("WScript.Shell")
  385.     Sh.RegWrite "HKCU\SOFTWARE\Stardock\DesktopX\Widget\Tiggz\K-Dock\sectionstring", sectionstring
  386.     Set Sh = Nothing
  387.     Set x = Nothing
  388.     Set sectionstring = Nothing    
  389. End Sub
  390.  
  391. Sub initializesections
  392. 't=title,s=status,eh=expanded height,ch=caption height,n=position,g=grouping
  393. 'g=1 shortcut section, g=2 weather or calendar
  394. ReDim sections(8)
  395. sections(0)="<t>weather</t><s>1</s><eh>128</eh><ch>30</ch><n>5</n><g>2</g>"
  396. sections(1)="<t>calendar</t><s>1</s><eh>128</eh><ch>30</ch><n>1</n><g>2</g>"
  397. sections(2)="<t>shortcuts1</t><s>1</s><eh>132</eh><ch>30</ch><n>6</n><g>1</g>"
  398. sections(3)="<t>calculator</t><s>1</s><eh>48</eh><ch>30</ch><n>2</n><g>0</g>"
  399. sections(4)="<t>media</t><s>1</s><eh>80</eh><ch>30</ch><n>3</n><g>0</g>"
  400. sections(5)="<t>controls</t><s>1</s><eh>80</eh><ch>30</ch><n>4</n><g>0</g>"
  401. sections(6)="<t>shortcuts2</t><s>0</s><eh>132</eh><ch>30</ch><n>7</n><g>1</g>"
  402. sections(7)="<t>shortcuts3</t><s>0</s><eh>132</eh><ch>30</ch><n>8</n><g>1</g>"
  403. sections(8)="<t>shortcuts4</t><s>0</s><eh>132</eh><ch>30</ch><n>9</n><g>1</g>"
  404. End Sub
  405.  
  406. '================================CALLBACKS================================
  407. Sub Object_OnMouseEnter
  408.     DesktopX.ScriptObject("kdocktooltip").tooltip(tt)
  409. End Sub
  410. Sub Object_OnMouseLeave
  411.     DesktopX.ScriptObject("kdocktooltip").tooltip("hide")
  412. End Sub]]></Script><Globals><Editor><PropPane>0</PropPane><EditorLeft>216</EditorLeft><EditorTop>-1</EditorTop><EditorRight>1011</EditorRight><EditorBottom>723</EditorBottom></Editor><Object><LanguageCLSID>{B54F3741-5B07-11CF-A4B0-00AA004A55E8}</LanguageCLSID><ControlCLSID>{00000000-0000-0000-0000-000000000000}</ControlCLSID><ControlObjWidth>64</ControlObjWidth><ControlObjHeight>64</ControlObjHeight><RunState>1</RunState><ManualControlLoad>0</ManualControlLoad><ScriptHostVersion>2</ScriptHostVersion></Object></Globals></DXScript>
  413.